﻿using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Documents;
using System.Data.OleDb;
using System.Data;
using System.Collections;
using DataMining.Bean;
using System.Data.SqlClient;
using DataMining.DataAccess.HospitalDataSetTableAdapters;
using DataMining.DataAccess;

namespace DataMining.Control.Transport
{
    class GetDB
    {
        /// <summary>
        /// DataCenter属性
        /// </summary>
        public string[] dc_attr;     

        /// <summary>
        /// DataWareHouse数据仓库属性
        /// </summary>
        public string[] dwh_attr;

        #region 通过Excel读取属性映射。输入：工作表名，输出：属性数组
        /// <summary>
        /// 从Excel读取属性映射
        /// </summary>
        /// <param name="excel_sheetname">工作表名称</param>
        /// <returns></returns>
        public void ReadFromExcel(string excel_sheetname)
        {
            DataTable dta = new DataTable();
            string ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:/bb.xls;Extended Properties='Excel 8.0;HDR=Yes;IMEX=0';";
            OleDbConnection cnnxls = new OleDbConnection(ConnStr);

            //读取Excel里面有表名为excel_sheetname
            OleDbDataAdapter oda = new OleDbDataAdapter("select * from [" + excel_sheetname + "$]", cnnxls);
            //将Excel里面有表内容装载到内存表中！
            oda.Fill(dta);

            //将MDT属性转化为string数组
            string[] datacenter_attr = new String[dta.Rows.Count];
            string[] datawarehouse_attr = new String[dta.Rows.Count];

            for (int i = 0; i < dta.Rows.Count-1; i++)
            {
                datacenter_attr[i] = dta.Rows[i-1][6].ToString();
                datawarehouse_attr[i] = dta.Rows[i-1][2].ToString();
            }
            dc_attr = datacenter_attr;
            dwh_attr = datawarehouse_attr;
        }
        #endregion

        /// <summary>
        /// 查询patient_information全部信息
        /// </summary>
        /// <param name="create_time">输入创建时间</param>
        /// <returns>输出datatable</returns>
        public DataTable getPatient_information_DataTable(DateTime create_time,PatientInformationAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询outpatient_record在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getOutpatient_Record_DataTable(DateTime create_time,Outpatient_RecordAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询inpatient_record在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getInpatient_Record_DataTable(DateTime create_time,Inpatient_RecordAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Outpatient_DrAdvice_Detail在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getOutpatient_DrAdvice_Detail_DataTable(DateTime create_time,Outpatient_DrAdvice_DetailAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Inpatient_DrAdvice_Detail在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getInpatient_DrAdvice_Detail_DataTable(DateTime create_time,Inpatient_DrAdvice_DetailAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Inpatient_Fee_Settle在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getIn_Fee_Settle_DataTable(DateTime create_time,Inpatient_Fee_SettleAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Outpatient_Fee_Settle在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getOut_Fee_Settle_DataTable(DateTime create_time,Outpatient_Fee_SettleAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Inpatient_Fee_Detail(住院收费明细)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getIn_Fee_Detail_DataTable(DateTime create_time,Inpatient_Fee_DetailAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Outpatient_Fee_Detail(门诊收费明细)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getOut_Fee_Detail_DataTable(DateTime create_time, Outpatient_Fee_DetailAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询Settle_Fee_Type(结算费别表)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getSettle_Fee_Type_DataTable(DateTime create_time,Settle_Fee_TypeAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询LIS_Report(检验报告单)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getLIS_Report_DataTable(DateTime create_time, LIS_ReportAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询LIS_Indicators(检验指标表)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getLIS_Indicators_DataTable(DateTime create_time,LIS_IndicatorsAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询CIS_Main(住院病历主表)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getCIS_Main_DataTable(DateTime create_time, CIS_MainAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }

        /// <summary>
        /// 查询CIS_Operation_Detail(住院病历手术明细表)在设定时间段的全部记录
        /// </summary>
        /// <param name="create_time">起始时间</param>
        /// <returns></returns>
        public DataTable getCIS_Operation_Detail_DataTable(DateTime create_time, CIS_Operation_DetailAccess access)
        {
            DataTable table = new DataTable();
            table = access.GetTable(create_time);
            return table;
        }



    }
}
